<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML >
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="content-type" content="text/html; charset=UTF-8">
<script>
        function isMobile()
        {
            var ua = navigator.userAgent.toLowerCase();
            var StringPhoneReg = "\\b(ip(hone|od)|android|opera m(ob|in)i"
                + "|windows (phone|ce)|blackberry"
                + "|s(ymbian|eries60|amsung)|p(laybook|alm|rofile/midp"
                + "|laystation portable)|nokia|fennec|htc[-_]"
                + "|mobile|up.browser|[1-4][0-9]{2}x[1-4][0-9]{2})\\b";
            var StringTableReg = "\\b(ipad|tablet|(Nexus 7)|up.browser"
                + "|[1-4][0-9]{2}x[1-4][0-9]{2})\\b";

            console.log(ua);
            var isIphone = ua.match(StringPhoneReg),
                isTable = ua.match(StringTableReg),
                isMobile = isIphone || isTable;

            if (isMobile) {
                // alert("你在用手机访问");
                window.location.href = "<%=basePath%>phone/pages/index_phone.html";
                return true;
            } else {
                 //alert("你在用电脑访问");
                window.location.href = "toIndex1";
                return false;
            }
        }

</script>
</head>
    <body onload="isMobile()">

</body>
</html>